package com.sgb.kjwl.view.ui.adapter.search;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.SearchDeviceOutEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.MDateUtil;

import java.util.List;

public class SearchDeviceOutAdapter extends BaseRecycleAdapter<SearchDeviceOutEntity> {

    private TextView contentView;
    private TextView priceView;

    public SearchDeviceOutAdapter(Context context, List<SearchDeviceOutEntity> datas) {
        super(context, R.layout.item_search_device_out, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final SearchDeviceOutEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        contentView = holder.getItem().findViewById(R.id.content_view);
        priceView = holder.getItem().findViewById(R.id.price_view);
        String time = MDateUtil.getByTimestamp(Long.parseLong(entity.getTime()), MDateUtil.Format.FORMART4.name);
        contentView.setText(entity.getCity() + "|" + entity.getTypeName() + "|" + time);

        if (entity.getPrice().equals("面议")) {
            priceView.setText(entity.getPrice());
        } else {
            priceView.setText(entity.getPrice() + entity.getUnitName());
        }


    }

}
